/* NOTICE
 
    Jim - the Java Image Manager, copyright (c) 2005 - 2007 Grant Gardner 
 
    Jim is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Jim is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
    In addition, as a special exception, you are permitted to link this code
    with the 3rd party libraries required to compile this file and to
    distribute a linked combination including them. You must obey the
    GNU General Public License in all respects for all of the code except for
    those 3rd party libraries that are licenced under terms incompatible with the
    GNU General Public License.  
 
 
 NOTICE */

package au.com.lastweekend.jim.model;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;

import javax.swing.Icon;

import au.com.lastweekend.jim.io.metadata.Tag;
import au.com.lastweekend.jim.swing.SwingUtil;

/**
 * 
 * @author grant@lastweekend.com.au
 * @version $Id: ContactSheetDirectoryItem.java,v 1.6 2006/02/20 12:22:44 ggardner Exp $
 */
public class ContactSheetDirectoryItem implements ContactSheetListItem {

    private static final Icon FOLDER = SwingUtil.createImageIcon("large_folder.png");

    private File _directory;

    public ContactSheetDirectoryItem(File directory) {

        _directory = directory;
    }

    /**
     * Creates list of contactSheetItems from a list of Directories
     * 
     * @param directoryImages
     * @return list of contactSheetItems
     */
    public static List<ContactSheetDirectoryItem> makeList(Collection<? extends File> directoryImages) {

        List<ContactSheetDirectoryItem> l = new ArrayList<ContactSheetDirectoryItem>();

        for (File file : directoryImages) {
            l.add(new ContactSheetDirectoryItem(file));
        }

        return l;
    }

    public File getFile() {

        return _directory;
    }

    public boolean allowsFileDrop() {

        return true;
    }

    public Icon getIcon() {

        return FOLDER;
    }

    public boolean isImported() {

        return false;
    }

    public boolean isPreviewAble() {

        return false;
    }

    public List<Tag> getAllTags() {

        return Collections.emptyList();
    }

    /**
     * No keywords for a directory
     * 
     * @return EMPTY_SET
     */
    public Set<String> getAllKeywords() {

        return Collections.emptySet();
    }

    /**
     * No rotation angle for a directory
     * 
     * @return 0
     */
    public int getRotationAngle() {

        return 0;
    }

    public int compareTo(ContactSheetListItem i) {

        if (i.getFile().isDirectory()) {
            return getFile().getName().compareTo(i.getFile().getName());
        } else {
            return -1;
        }
    }

    public void updateKeywordSelection(String imageBaseString, boolean selected) {

        // Do nothing.... 

    }
}
